package cn.tedu.medicalappointmentsystemk.dao.persist.repository.impl;

import cn.tedu.medicalappointmentsystemk.dao.persist.mapper.PatientMapper;
import cn.tedu.medicalappointmentsystemk.dao.persist.repository.PatientRepository;
import cn.tedu.medicalappointmentsystemk.pojo.bo.PatientSelectBO;
import cn.tedu.medicalappointmentsystemk.pojo.po.PatientPO;
import cn.tedu.medicalappointmentsystemk.pojo.vo.PatientUpdateVO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;

@Slf4j
@Repository
public class PatientRepositoryImpl implements PatientRepository {

    @Autowired
    private PatientMapper mapper;

    @Override
    public Integer addNew(PatientPO po) {
        return mapper.insert(po);
    }

    @Override
    public PatientPO selectDetailById(Long id) {
        QueryWrapper<PatientPO> queryWrapper=new QueryWrapper<>();
        queryWrapper.eq("id",id);
        return mapper.selectOne(queryWrapper);
    }

    @Override
    public Page<PatientSelectBO> select() {
        return mapper.select();
    }

    @Override
    public Integer deleteById(Long id) {
        return mapper.deleteById(id);
    }

    @Override
    public Integer update(PatientUpdateVO vo) {
        return mapper.update(vo);
    }

    @Override
    public Page<PatientSelectBO> searchLastWeek() {
        return mapper.searchLastWeek();
    }

    @Override
    public Page<PatientSelectBO> searchLastMonth() {
        return mapper.searchLastMonth();
    }

    @Override
    public Page<PatientSelectBO> searchToday() {
        return mapper.searchToday();
    }

    @Override
    public List<PatientSelectBO> select(String nickname) {
        return mapper.selectByName(nickname);
    }
}
